<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            width: 90px;
            height: 90px;
        }
    </style>
</head>
<body>
    <div>
        <img src="../images/empty.png" alt="">
        <img src="../images/empty.png" alt="">
        <img src="../images/empty.png" alt="">
        <img src="../images/empty.png" alt="">
        <img src="../images/empty.png" alt="">
    </div>
    <script>
        let imgs = document.querySelectorAll("img");
        let index = 0;
        for(let i = 0;i < imgs.length;i++){
            imgs[i].onmouseover = function(){
                if(index > 0){
                    return;
                }
                for(let j = 0;j < imgs.length;j++){
                    if(j <= i){
                        imgs[j].src = "../images/full.png";
                    }else{
                        imgs[j].src = "../images/empty.png";
                    }
                }
            }
            imgs[i].onmouseout = function(){
                if(index > 0){
                    return;
                }
                imgs.forEach((img) => img.src = "../images/empty.png")
            }
            imgs[i].onclick = function(){
                index = i;
            }
        }
    </script>
</body>
</html>